@extends('back.common.layout')
@section('title', '代码生成')

@section('content')

    <div id="content">
        <div class="page-header">
            <div class="container-fluid">
                <div class="pull-right">
                    <button type="submit" form="form-brand" data-toggle="tooltip" title="保存" class="btn btn-primary"><i
                            class="fa fa-save"></i>
                    </button>
                    <a href="{{route('code.generate')}}" data-toggle="tooltip" title="取消" class="btn btn-default"> <i class="fa fa-reply"></i>
                    </a>
                </div>
                <h1>模块生成</h1>
                <ul class="breadcrumb">
                    <li>
                        <a href="#">首页</a>
                    </li>
                    <li>
                        <a href="{{route('code.generate')}}">模块生成</a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="container-fluid">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <i class="fa fa-pencil"></i>
                        添加模块
                    </h3>
                </div>
                <div class="panel-body">
                    <form action="{{route('code.generate',[$type])}}" method="post" enctype="multipart/form-data"
                          id="form-generate" class="form-horizontal">
                        {{ csrf_field() }}
                        <ul class="nav nav-tabs">
                            <li class="@if($type == 'table') active @endif">
                            <a>表信息</a>
                            </li>
                            <li class="@if($type == 'field') active @endif">
                            <a>字段信息</a>
                            </li>
                        </ul>
                        @if ($type == 'table')
                        <div class="tab-content">
                            <div class="tab-pane @if($type == 'table') active @endif" id="tab-table">
                                <div class="form-group required">
                                    <label class="col-sm-2 control-label" for="input-table">表名</label>
                                    <div class="col-sm-10">
                                        <input type="text" name="table" value="" placeholder="无前缀表名" id="input-table" class="form-control"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" for="input-title">表展示标题</label>
                                    <div class="col-sm-10">
                                        <input type="text" name="title" value="" placeholder="展示标题, 默认使用表名" id="input-title" class="form-control">
                                    </div>
                                </div>
                            </div>
                        </div>
                        @endif
                        @if (isset($fieldList))
                        <div class="tab-pane @if($type == 'field') active @endif" id="tab-field">
                            <div class="row">
                                <div class="col-sm-12">
                                    <table id="table-field" class="table table-striped table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <td class="text-left">字段</td>
                                            <td class="text-left">展示标题</td>
                                            <td class="text-center">是否设置</td>
                                            <td class="text-center">是否列表</td>
                                            <td class="text-center">是否排序</td>
                                            <td class="text-center">是否搜索</td>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        @foreach ($fieldList as $field)
                                            <tr id="tr-field-title">
                                                <td class="text-left">
                                                    {{$field}}
                                                </td>
                                                <td class="text-left">
                                                    <input name="field[{{$field}}][title]" value="" placeholder="标题" class="form-control" type="text">
                                                </td>
                                                <td class="text-center">
                                                    <input type="checkbox" name="field[{{$field}}][is_set]" value="1">
                                                </td>

                                                <td class="text-center">
                                                    <input type="checkbox" name="field[{{$field}}][is_list]" value="1" checked>
                                                </td>
                                                <td class="text-center">
                                                    <input type="checkbox" name="field[{{$field}}][is_sort]" value="1">
                                                </td>
                                                <td class="text-center">
                                                    <input type="checkbox" name="field[{{$field}}][is_search]" value="1" disabled>
                                                </td>
                                            </tr>
                                        @endforeach
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        @endif
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection